/**
   异步加载原生高德地图
**********/
export default async function MapLoader(apiKey: string) {
  return new Promise((resolve, reject) => {
    // 创建script标签
    const script = document.createElement("script");
    // 设置标签的type属性
    script.type = "text/javascript";
    // 设置标签的链接地址
    script.src = `https://webapi.amap.com/maps?v=2.0&key=${apiKey}&plugin=AMap.Geocoder,AMap.DistrictSearch`;
    script.onload = () => {
      resolve(true);
    };
    // 监听脚本加载失败事件
    script.onerror = (error) => {
      reject(error);
    };
    // 添加标签到dom中
    document.head.appendChild(script);
  });
}
